package com.draven.xkclass.controller.admin;

import com.draven.xkclass.domain.Video;
import com.draven.xkclass.service.VideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/admin/api/v1/video")
public class VideoAdminController {

    @Autowired
    private VideoService videoService;

    /**
     * 根据id删除视频
     * @param videoId
     * @return
     */
    @DeleteMapping("/del_by_id")
    public Object delById(@RequestParam(value = "video_id",required = true) int videoId) {
        return videoService.delete(videoId);
    }

    /**
     * 根据id更新视频
     * @param video
     * @return
     */
    @PutMapping("/update_by_id")
    public Object update(@RequestBody Video video) {

        return videoService.update(video);
    }

    /**
     * 保存视频对象
     * @param video
     * @return
     */
    @PostMapping("/save")
    public Object save(Video video) {
        int rows = videoService.save(video);
        log.info("保存对象的id= " + video.getId());
        return rows;
    }
}
